module.exports = {
    add(colObj,data={}){
        return new Promise((resolve, reject) => {
            colObj.insertMany(data,err=>{
                if(err){
                    reject(err)
                }else{
                    resolve()
                }
            })
        })
    },
    remove(colObj,where,num=1){
        let type = num===1?"deleteOne":"deleteMany";
        return new Promise((resolve, reject) => {
            colObj[type](where,err=>{
                if(err){
                    reject(err)
                }else{
                    resolve()
                }
    
            })
        })
    },
    set(colObj,where,data,num=2){
        let type = num===1?"updateOne":"updateMany";
       return new Promise((resolve, reject) => {
            colObj[type](where,data,err=>{
                if(err){
                    reject(err)
                }else{
                    resolve();
                }
            })
       })
    },
    get(colObj,where={}){
        return new Promise((resolve, reject) => {
            colObj.find(where,{__v:0},(err,data)=>{
                if(err){
                    reject(err)
                }else{
                    resolve(data)
                }
            })
        })
    }
}